﻿using System;
using System.Collections;
using System.Configuration;

namespace DevOnServer
{
    public partial class CDatabase
    {
        public bool init(CGameServer server)
        {
            m_server = server;

            Hashtable section = (Hashtable)ConfigurationManager.GetSection("MySql");

            if (!m_dbc.connect((string)section["host"], Convert.ToInt32(section["port"]),
                (string)section["username"], (string)section["password"], (string)section["dbname"]))
            {
                CConsole.WriteLine("Can't connect to MySql database...");
                return false;
            }
            else
            {
                CConsole.WriteLine("Connected to database '{0}'", section["dbname"]);
                return true;
            }
        }

        private CDatabaseConnection m_dbc = new CDatabaseConnection();

        private CGameServer m_server;
    }
}